package leetcode.violence;

public class q {
    public static void main(String[] args) {
        System.out.println(pProcess2(6,6));
    }
    public static int pProcess(int n,int m){
        if (n<1 || m<1){
            return 0;
        }
        if (n==1 || m==1){
            return 1;
        }
        if (n==m){
            return 1+pProcess(n,m-1);
        }
        if (n<m){
            return pProcess(n,n);
        }
        return pProcess(n,m-1)+pProcess(n-m,m);
    }
    public static int pProcess2(int n,int m){
        int[][] arr = new int[n+1][m+1];
        for (int i = 1; i <=n; i++) {
            for (int j = 1; j <=m; j++) {
                if (i<1 || j<1){
                    arr[i][j] = 0;
                }
                if (i == j){
                    arr[i][j] = arr[i][j-1]+1;
                }else if (i<j){
                    arr[i][j] = arr[i][i];
                }else
                arr[i][j] = arr[i][j-1]+arr[i-j][j];
            }
        }
        return arr[n][m];
    }
}
